package pers.zc.activiti.thread.demo;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

/**
 * @description future测试
 * @Author Lin FuYuan
 * @date 2020/4/17
 */
@Service
public class FutureClass1 {
    @Async("testThreadPool")
    public Future<Integer> test(){
        for (int i = 0; i <10 ; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                System.out.println("InterruptedException异常");
                return new AsyncResult<>(1);
            }
            System.out.println("future1 "+i+" "+Thread.currentThread().getName());
        }
        return new AsyncResult<>(1);
    }
}
